package chapter6;
/****************************************************************
 * Author：icynlau
 * Description: 掷色子游戏
 * Date:2021/4/6
 * ***************************************************************
 */
public class exc6_30 {
	
	public static int craps() {
		
		int dice1=(int)(Math.random()*6+1);
		int dice2=(int)(Math.random()*6+1);
		System.out.printf("You rooled %d+%d=%d\n",dice1,dice2,dice1+dice2);
		
		return dice1+dice2;
	}
	
	public static void main(String[] args) {
		
		int tmp=craps();
		
		if(tmp==2||tmp==3||tmp==12) {
			System.out.print("You lose.\n");
		}else if(tmp==7||tmp==11) {
			System.out.print("You win.\n");
		}else {
			//4 5 6 8 9 10
			
			int last=0;
			
			do {
				
				last=tmp;
				System.out.printf("point is %d\n",last);
				tmp=craps();
				
			}while(tmp!=last && tmp!=7);
			
			if(tmp==last&&tmp!=7) {
				
				System.out.print("You win.\n");
				
			}else {
				//7
				System.out.print("You lose.\n");
			}
		}
		
	}

}
